<?php
class Config {
	public $config = array ();
	
	static public function Set($mixed, $value = null) {
		$instance = self::Instance ();
		return $instance->setvar ( $mixed, $value );
	}
	
	public function Get($key) {
		$instance = self::Instance ();
		return $instance->getvar ( $key );
	}
	
	private function setvar($mixed, $value = nulls) {
		if (is_array ( $mixed )) {
			$this->config = array_merge ( $this->config, $mixed );
		} elseif ($mixed != '' && is_string ( $mixed )) {
			$this->config [$mixed] = $value;
		}
	}
	
	private function getvar($key) {
		if (strpos ( $key, '.' ) !== false) {
			$k = explode ( '.', $key );
			switch (count ( $k )) {
				case 1 :
					$value = $this->config [$k [0]];
					break;
				case 2 :
					$value = $this->config [$k [0]] [$k [1]];
					break;
				case 3 :
					$value = $this->config [$k [0]] [$k [1]] [$k [2]];
					break;
				case 4 :
					$value = $this->config [$k [0]] [$k [1]] [$k [2]] [$k [3]];
					break;
				default :
					$value = false;
			}
		} else {
			$value = $this->config [$key];
		}
		return $value;
	}
	
	public function Instance() {
		static $instance = '';
		if ($instance === '') {
			$instance = new Config ( );
		}
		return $instance;
	}

}
?>